function infoLog(){
  let args = getArgumentsInfo(arguments) || false;
  if(args){
    console.log.apply(null, args);
  }
}

function errorLog() {
  let args = getArgumentsInfo(arguments) || false;
  if (args) {
    console.error.apply(null, args);
  }
}

function getArgumentsInfo(arg) {
  try {
    throw arg.callee
  } catch (er) {
    let args = Array.prototype.slice.call(arg);
    let system = wx.getSystemInfoSync();
    let platform = system.platform;
    let str = er.stack.toString();
    let arr = str.split('\n');
    let matchArr = [];
    let matchStr = 'at G.';

    if (platform == 'ios') matchStr = '@[native code]';
    else if (platform == 'android') matchStr = 'at H.';

    arr.forEach((item) => {
      if (item.indexOf(matchStr) != -1) {
        item = item.trim();
        if (platform == 'ios') {
          matchArr.push(item.slice(0, item.indexOf(matchStr)).trim());
        } else {
          matchArr.push(item.slice(matchStr.length, item.indexOf('(')).trim());
        }
      }
    })

    if (platform != 'ios') {
      matchArr.pop();
      matchArr.pop();
    }

    matchArr.reverse();
    matchArr.push('■■■■■■■■\n');

    // console.log.apply(null, [(matchArr.join('()===>'))].concat(args))
    return [(matchArr.join('()===>'))].concat(args);
  }
}

export default {
  infoLog,
  errorLog,
}